* Dickstein, Ho, and Mark (2023)
* Create moral hazard and risk aversion graphs in STATA, using results from moral_hazard_risk_aversion.R 

cap program drop set_grstyle
program define set_grstyle
	grstyle init
	grstyle set plain
end

cd ../..
global build = "build/identification"
global release = "release/identification"

* Risk Aversion Plot
use "$build/riskaversion_switchers.dta", clear

replace expected_lambda = expected_lambda*100 // so that units are in $s per month

set_grstyle
tw (scatter prob_gold expected_lambda if expl_market == "SG", mcolor("dknavy")) || ///
	(scatter prob_gold expected_lambda if expl_market == "Ind", mcolor("dkorange")) ///
	(lfit prob_gold expected_lambda if expl_market == "SG", lcolor("dknavy")) ///
	(lfit prob_gold expected_lambda if expl_market == "Ind", lcolor("dkorange")) ///
	, legend(label(1 "Small group market") label(2 "Individual market") label(3 "Best fit, small group") label(4 "Best fit, individual") region(lstyle(none))) ///
	xtitle("non-discretionary spending") ytitle("gold plan share")
graph export "$release/risk_aversion_plot.eps", replace  

* Moral Hazard Plots for SG switcher population
foreach m in 2 3 4 {
	use "$build/moralhazard_switchers_metal`m'.dta", clear
	replace expected_lambda = expected_lambda*100 
	
	set_grstyle
	tw (scatter median_spending expected_lambda if expl_market == "SG", mcolor("dknavy")) || ///
		(scatter median_spending expected_lambda if expl_market == "Ind", mcolor("dkorange")) ///
		(lfit median_spending expected_lambda if expl_market == "SG", lcolor("dknavy")) ///
		(lfit median_spending expected_lambda if expl_market == "Ind", lcolor("dkorange")) ///
		, legend(off) xtitle("non-discretionary spending") ytitle("total spending") ylab(0(100)400) ///
		ysize(6) xsize(4)
	graph export "$release/moralhazard_switchers_metal`m'.eps", replace  
}
